/********************************************************************************
* @Author: Zhenzhou Liu
* @Date: 2024-11-17
* @Description: Cg分支算法刷题
********************************************************************************/
#include <iostream>
#include <vector>
#include <string>
#include <sstream>

using namespace std;

void mergeSortForMerge(vector<int>& nums, int low, int midden, int high)
{
    vector<int> temp(nums.begin() + low, nums.begin() + high + 1);
    int i = 0, limit1 = midden - low, j = limit1 + 1, limit2 = high - low, k = low;
    while (i <= limit1 && j <= limit2)
    {
        if (temp[i] < temp[j])
            nums[k++] = temp[i++];
        else
            nums[k++] = temp[j++];
    }
    while (i <= limit1)
        nums[k++] = temp[i++];
    while (j <= limit2)
        nums[k++] = temp[j++];
}

void mergeSort(vector<int>& nums, int low, int high)
{
    if (low < high)
    {
        int midden = low + ((high - low) >> 1);
        mergeSort(nums, low, midden);
        mergeSort(nums, midden + 1, high);
        mergeSortForMerge(nums, low, midden, high);
    }
}

void printVectorInt(const vector<int>& nums);
int main()
{
    vector<int> nums;
    string line, token;

    getline(cin, line);
    istringstream iss(line);

    // 解析输入数据
    while (getline(iss, token, ','))
    {
        try
        {
            nums.push_back(stoi(token));
        }
        catch (const invalid_argument& e)
        {
            cerr << "无效的输入：" << token << " 不是有效的整数" << endl;
            return 1;
        }
        catch (const out_of_range& e)
        {
            cerr << "数值超出范围：" << token << endl;
            return 1;
        }
    }
    mergeSort(nums, 0, nums.size() - 1);
    printVectorInt(nums);
    return 0;
}

void printVectorInt(const vector<int>& nums)
{
    for (size_t i = 0; i < nums.size(); ++i)
    {
        if (i > 0)
            cout << ',';
        cout << nums[i];
    }
}
